package ru.serverpush.web.service;

import org.springframework.web.context.request.async.DeferredResult;

import java.util.concurrent.*;

/**
 * Created with IntelliJ IDEA.
 * User: smeshkov
 * Date: 05/11/13
 * Time: 23:24
 * To change this template use File | Settings | File Templates.
 */


public class ResultService {

    private static volatile ResultService that;
    private final ExecutorService executor;
    private final CompletionService<ResultHolder> service;

    private ResultService(){
        executor = Executors.newCachedThreadPool();
        service = new ExecutorCompletionService<ResultHolder>(executor);
    }

    public static ResultService getInstance() {
        if (that == null) {
            synchronized (ResultService.class) {
                if(that == null) {
                    that = new ResultService();
                }
            }
        }
        return that;
    }

    public void submit(DeferredResult<ResultHolder> result) {
//        service.submit();
    }

}
